<template>
	<div v-cloak class="aui-wrapper aui-page__iframe">
		<div class="aui-content__wrapper">
			<div class="aui-content">
				<el-card shadow="never" class="aui-card--fill">
					<div class="mod-WCSTask">
						<div>
								<el-button   size="small"  @click="getDataList()">刷新</el-button>
						</div>
						<el-table v-loading="dataListLoading" :data="dataList" border style="width: 100%;">
							<el-table-column prop="task_id" label="任务号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="task_type" label="任务类型" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="task_status" label="任务状态" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="priority" label="优先级" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="type" label="WMS类型" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="locate_from" label="自库位" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="locate_to" label="至库位" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="tary_from" label="自托盘" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="tary_to" label="至托盘" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="GETX" label="堆垛机取X" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="GETY" label="堆垛机取Y" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="GETZ" label="堆垛机取Z" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="PUTX" label="堆垛机放X" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="PUTY" label="堆垛机放Y" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="PUTZ" label="堆垛机放Z" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="fromlane" label="取巷道" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="tolane" label="放巷道" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="export" label="出口" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="create_date" label="时间" header-align="center" align="center">
							</el-table-column>
							<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
								<template #default="scope">
									<el-button type="text" size="small" @click="changeWCSFn(scope.row.task_id,'DONE')">
										完成</el-button>
									<el-button type="text" size="small"
										@click="changeWCSFn(scope.row.task_id,'DELETE')">删除</el-button>
								<!-- 	<el-button type="text" size="small" @click="changeWCSFn(scope.row.task_id,'CANCE')">
										取消</el-button> -->
								</template>
							</el-table-column>
						</el-table>
					</div>
				</el-card>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import {
		getWCSTask,changeWCS
	} from '@/network/lswms/WCS/WCS.js';
	import {
		ElMessage,
		ElMessageBox
	} from 'element-plus'
	export default {
		name: "WCStask",
		setup() {
			const dataList = ref([]);
			const dataListLoading = ref(false);
			const getDataList = () => {
				dataListLoading.value = true;
				getWCSTask().then((res) => {
					if (res.code != 0) {
						return ElMessage.error(res.msg);
						dataListLoading.value = false;
					}
					dataList.value = res.data;
					dataListLoading.value = false;
				})
			}
			onMounted(() => {
				getDataList();
			})

			const changeWCSFn = (taskid, type) => {
				let typeStr ="";
				if(type=='DONE'){
					typeStr = "完成"
					
				}else if(type=='DELETE'){
					typeStr = "删除"
				}
				else if(type=='CANCE'){
					typeStr = "取消"
				}
				
				ElMessageBox.confirm('确定要'+typeStr+taskid+'的WCS的任务吗?请谨慎操作', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(function() {
					let data = {
						taskid: taskid.toString(),
						type
					}
					changeWCS(data).then((res) => {
						if (res.code != 0) {
							return ElMessage.error(res.msg);
						}
						getDataList();
					})
				})
			}

			return {
				dataList,
				getDataList,
				changeWCSFn,
				dataListLoading
			}
		}
	}
</script>

<style>
</style>
